package com.kmproject.haifu.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.kmproject.haifu.mvp.contract.PersonalHpRentingListContract;
import com.kmproject.haifu.mvp.model.api.Api;
import com.kmproject.haifu.mvp.model.api.service.UserService;
import com.kmproject.haifu.mvp.model.entity.ResultBean;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowInfoBean;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 *
 */
@ActivityScope
public class PersonalHpRentingListModel extends BaseModel implements PersonalHpRentingListContract.Model {
    private Gson mGson;
    private Application mApplication;
    private UserService userService;

    @Inject
    public PersonalHpRentingListModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
        userService = repositoryManager.obtainRetrofitService(UserService.class);
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> getHouseRentByUser(String limit, String page, String userId, String houseCategory) {
        return userService.getHouseRentByUser(limit, page, userId, houseCategory);
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> listHouseRent4Store(String limit, String page, String storeId, Map<String, Object> maps) {
        return userService.listHouseRent4Store(Api.LIST_HOUSE_RENT_STORE, limit, page, storeId, creatRequestBody(maps, mGson));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }
}